home *** CD-ROM | disk | FTP | other *** search
- /********************************
- Program name: PrintWindow.c
- *********************************/
- /**********************
- Include files
- ***********************/
- #include "String.h"
- #include "MyWindow.h"
- #include "Messenger.h"
-
- /**********************
- main() main entry point
- ***********************/
- void main()
- { /* main() */
- char doneFlag;
- char stillInGoAway;
- char ch;
- short code;
- short theMenu,theItem;
- short chCode;
- long mResult;
- WindowPtr whichWindow;
- EventRecord myEvent;
- TEHandle theInput;
- Rect tempRect,OldRect;
- Point myPt;
- GrafPtr SavePort;
-
- /* Initialize everything */
- InitGraf(&thePort);
- InitFonts();
- FlushEvents(everyEvent,0);
- InitWindows();
- InitMenus();
- TEInit();
- InitDialogs(NULL);
- InitCursor();
-
- InitPrint();
- InitMyMenus();
- InitMessage();
- Init_MyWindow();
-
- doneFlag = FALSE;
- theInput = NULL;
-
- /* open the MyWindow */
- Open_MyWindow(&theInput);
-
- do { /* main event loop */
- if (theInput != NULL)
- TEIdle(theInput);
- SystemTask();
-
- if (GetNextEvent(everyEvent, &myEvent)) { /* get an event */
- code = FindWindow(myEvent.where, &whichWindow);
-
- switch (myEvent.what) { /* handle an event */
- case mouseDown:
- if (code == inMenuBar) {
- mResult = MenuSelect(myEvent.where);
- theMenu = HiWord(mResult);
- theItem = LoWord(mResult);
- HandleMenu(&doneFlag,theMenu,theItem);
- }
-
- if ((code == inDrag)&&(whichWindow != NULL)) {
- tempRect = screenBits.bounds;
- SetRect(&tempRect,
- tempRect.left + 10, tempRect.top + 25,
- tempRect.right - 10, tempRect.bottom - 10);
- DragWindow(whichWindow, myEvent.where, &tempRect);
- }
-
- if (code == inGrow) {
- SetPort(whichWindow);
-
- myPt = myEvent.where;
- GlobalToLocal(&myPt);
- OldRect = whichWindow->portRect;
-
- SetRect(&tempRect,15,15,
- (screenBits.bounds.right - screenBits.bounds.left),
- (screenBits.bounds.bottom - screenBits.bounds.top) - 20);
- mResult = GrowWindow(whichWindow, myEvent.where, &tempRect);
- SizeWindow(whichWindow, LoWord(mResult), HiWord(mResult), TRUE);
-
- Resized_MyWindow(&OldRect, whichWindow);
-
- SetPort(whichWindow);
-
- SetRect(&tempRect, 0, myPt.v - 15, myPt.h + 15, myPt.v + 15);
- EraseRect(&tempRect);
- InvalRect(&tempRect);
- SetRect(&tempRect, myPt.h - 15, 0, myPt.h + 15, myPt.v + 15);
- EraseRect(&tempRect);
- InvalRect(&tempRect);
- DrawGrowIcon(whichWindow);
- }
-
- if (code == inGoAway) {
- stillInGoAway = TrackGoAway(whichWindow,myEvent.where);
- if (stillInGoAway == TRUE)
- Close_MyWindow(whichWindow,&theInput);
- }
-
- if (code == inContent) {
- if (whichWindow != FrontWindow())
- SelectWindow(whichWindow);
- else {
- SetPort(whichWindow);
- Do_MyWindow (&myEvent,&theInput );
- }
- }
-
- if (code == inSysWindow)
- SystemClick(&myEvent, whichWindow);
- break; /* End of mouseDown */
-
- case keyDown:
- case autoKey:
- ch = myEvent.message & charCodeMask;
- if (myEvent.modifiers & cmdKey) {
- mResult = MenuKey(ch);
- theMenu = HiWord(mResult);
- theItem = LoWord(mResult);
- if (theMenu != 0)
- HandleMenu(&doneFlag, theMenu, theItem);
- if (((ch == 'x') || (ch == 'X')) && (theInput != NULL))
- TECut(theInput);
- if (((ch == 'c') || (ch == 'C')) && (theInput != NULL))
- TECopy(theInput);
- if (((ch == 'v') || (ch == 'V')) && (theInput != NULL))
- TEPaste(theInput);
- }
- else if (theInput != NULL)
- TEKey(ch,theInput);
- break;
-
- case updateEvt:
- whichWindow = (WindowPtr)myEvent.message;
- GetPort(&SavePort);
- BeginUpdate(whichWindow);
- SetPort(whichWindow);
- UpDate_MyWindow(whichWindow);
- EndUpdate(whichWindow);
- SetPort(SavePort);
- break;
-
- case diskEvt:
- if (HiWord(myEvent.message) != 0) {
- myEvent.where.h = ((screenBits.bounds.right - screenBits.bounds.left) / 2) - (304 / 2);
- myEvent.where.v = ((screenBits.bounds.bottom - screenBits.bounds.top) / 3) - (104 / 2);
- InitCursor();
- theItem = DIBadMount(myEvent.where, myEvent.message);
- }
- break;
-
- case activateEvt:
- if ((whichWindow != NULL) && (myEvent.modifiers & activeFlag)) {
- SelectWindow(whichWindow);
- DrawGrowIcon(whichWindow);/* Update this window */
- }
- break;
-
- default:
- break;
- } /* handle an event */
- } /* get an event */
- } while (doneFlag == FALSE); /* main event loop */
- } /* main() */